package top.whysu.edevice.system;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import top.whysu.edevice.service.system.SystemConfigService;

import javax.annotation.Resource;

/**
 * 服务启动初始化类
 */
@Component
@Order(value = 1)
public class InitServlet implements ApplicationRunner {
    private static final Logger LOGGER = LoggerFactory.getLogger(InitServlet.class);
    private static final long serialVersionUID = 2046816427662214819L;
    @Resource
    private SystemConfigService systemConfigService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        LOGGER.info("系统配置及线程池配置缓存预热");
        // 系统配置预热
        systemConfigService.initializeSystemconfigCache();
        // 线程池配置预热
        systemConfigService.initializeThreadPoolConfigCache();
    }


}
